#include "Connected.hpp"

Connected::Connected()
  : ReadBuf(NULL, 0, -1)
{
}


Connected::~Connected()
{
}

int	Connected::CheckCompleteBuf()
{
  int                   bufferSize;
  int                   alreadyRead;

  bufferSize = ReadBuf.GetBufferSize();
  alreadyRead = ReadBuf.GetAlreadyRead();
  if (bufferSize == alreadyRead)
    {
      ReadBuf.SetBuffer(NULL);
      ReadBuf.SetAlreadyRead(-1);
      ReadBuf.SetBufferSize(0);
      return (0);
    }
  return (-1);
}

int	Connected::AddListWrite(char	*buff,
				int	sizeBuf)
{
  int	i;
  char	*b;

  b = new char[sizeBuf];
  for (i = 0; i < sizeBuf; ++i)
    b[i] = buff[i];
  WriteBuf.push_back(new Buffer(b, sizeBuf, -1));
  return (0);
}

int   Connected::GetFd(void)
{
  return Fd;
}

void   Connected::SetFd(int fd)
{
  Fd = fd;
}

Buffer &Connected::GetReadBuf(void)
{
  return ReadBuf;
}

std::list<Buffer *>   &Connected::GetWriteBuf(void)
{
  return WriteBuf;
}
